home *** CD-ROM | disk | FTP | other *** search
- unit uAccessoriesMenu;
-
- {
- *******************************************************************************
- * Descriptions: Accessories Menu for Ericsson Phone Implementation
- * $Source: /cvsroot/fma/fma/uAccessoriesMenu.pas,v $
- * $Locker: $
- *
- * Todo:
- *
- * Change Log:
- * $Log: uAccessoriesMenu.pas,v $
- * Revision 1.10 2004/05/19 18:34:15 z_stoichev
- * Build 0.1.0.35c
- *
- * Revision 1.9 2004/02/03 16:13:01 z_stoichev
- * Fixed Accessories menu Init works in offline mode.
- * Fixed am.TxAndWait execute is synced with other TxAndWait calls.
- *
- * Revision 1.8 2004/01/27 15:54:28 z_stoichev
- * menu cleanups.
- *
- * Revision 1.7 2004/01/23 08:28:16 z_stoichev
- * Added missing "
- *
- * Revision 1.6 2003/12/18 12:45:39 z_stoichev
- * Carpedi3m requested implementations.
- *
- * Revision 1.5 2003/11/28 09:38:07 z_stoichev
- * Merged with branch-release-1-1 (Fma 0.10.28c)
- *
- * Revision 1.4.2.1 2003/10/27 07:22:54 z_stoichev
- * Build 0.1.0 RC1 Initial Checkin.
- *
- * Revision 1.4 2003/07/02 12:43:14 crino77
- * added dlginformation
- *
- * Revision 1.3 2003/01/30 04:15:57 warren00
- * Updated with header comments
- *
- *
- *******************************************************************************
- }
-
- {$WARN SYMBOL_PLATFORM OFF}
-
- interface
-
- uses
- ComObj, ActiveX, MobileAgent_TLB, StdVcl, Classes, SysUtils;
-
- type
- TAccessoriesMenu = class(TAutoObject, IAccessoriesMenu)
- private
- FTitle: String;
- FMenuList: TStrings;
- protected
- procedure Init; safecall;
- procedure Clear; safecall;
- procedure AddItem(const Caption, Event: WideString); safecall;
- procedure Set_Title(const Value: WideString); safecall;
- procedure Set_Selected(Value: Integer); safecall;
- procedure Update; safecall;
- procedure Set_Back(const Value: WideString); safecall;
- procedure ClearMenu; safecall;
- procedure Set_NextState(Value: Integer); safecall;
- procedure DlgOption; safecall;
- procedure DlgMsgBox(const Msg: WideString; TimeoutS: Integer); safecall;
- procedure DlgYesNo(const Msg, Event: WideString; TimeoutS: Integer); safecall;
- procedure DlgOnOff(const Title, Event: WideString; Default: Integer); safecall;
- procedure DlgPercent(const Title, Event: WideString; Steps, Pos: Integer); safecall;
- procedure DlgInputStr(const Title, Prompt: WideString; MaxLen: Integer;
- const DefaultStr: WideString; const Event: WideString); safecall;
- procedure DlgInputInt(const Title, Prompt: WideString; MinVal, MaxVal,
- DefaultVal: Integer; const event: WideString); safecall;
- procedure DlgInformation(const Title, Msg: WideString); safecall;
- procedure DlgFeedback(const Title, event: WideString); safecall;
- { Protected declarations }
- public
- FSelected: Integer;
- FBack: String;
- FEventList: TStrings;
- FNextState: Integer;
- FGeneralEvent: String;
- procedure Initialize; override;
- destructor Destroy; override;
- end;
-
- implementation
-
- uses ComServ, Unit1;
-
- procedure TAccessoriesMenu.Init;
- begin
- if Form1.FConnected then Form1.ScheduleTxAndWait('AT*EAM="FMA"');
- Clear;
- end;
-
- procedure TAccessoriesMenu.Clear;
- begin
- ClearMenu;
-
- FTitle := '';
- FSelected := 1;
- FNextState := 1;
- end;
-
- procedure TAccessoriesMenu.AddItem(const Caption, Event: WideString);
- begin
- FMenuList.Add(Caption);
- FEventList.Add(Event);
- end;
-
- procedure TAccessoriesMenu.Set_Title(const Value: WideString);
- begin
- FTitle := Value;
- end;
-
- procedure TAccessoriesMenu.Set_Selected(Value: Integer);
- begin
- FSelected := Value;
- end;
-
- procedure TAccessoriesMenu.Update;
- var
- Com: String;
- Buf, TempBuf: String;
- ComLen, ComCount: Integer;
- i: Integer;
- begin
- {
- AT*EASM=<title>,<next_state>,<selected_item>,<number_of_menu_items>[,<menu_item>[,<menu_item>, ...]][,<final_flag>]
- }
-
- Form1.Debug('Updating Accessories Menu');
-
- // Prepare start of AT command
- Com := 'AT*EASM="' + FTitle + '",' + IntToStr(FNextState) + ',' + IntToStr(FSelected) + ',';
- ComLen := Length(Com);
-
- // Reset all flags and buffers
- ComCount := 0;
- Buf := '';
- TempBuf := '';
-
- // Build menu
- for i := 0 to FMenuList.Count - 1 do begin
- // Add menu item
- TempBuf := ',"' + FMenuList.Strings[i] + '"';
- // Check if AT command is not too long
- if (ComLen + Length(Buf) + Length(TempBuf)) > 200 then
- begin
- // It is too long, set final_flag to 0, we will continue
- Buf := Com + IntToStr(ComCount) + Buf + ',0';
- // Send AT command
- Form1.TxAndWait(Buf);
-
- // Store last item to buffer
- Buf := TempBuf;
- ComCount := 1;
- end
- else
- begin
- // Add menu item and increase counter of items in one command
- Buf := Buf + TempBuf;
- Inc(ComCount);
- end;
- end;
-
- // Send rest of menu to phone with final_flag set to 1
- Buf := Com + IntToStr(ComCount) + Buf + ',1';
- Form1.TxAndWait(Buf);
- end;
-
- procedure TAccessoriesMenu.Set_Back(const Value: WideString);
- begin
- FBack := Value;
- end;
-
- procedure TAccessoriesMenu.ClearMenu;
- begin
- FMenuList.Clear;
- FEventList.Clear;
- FBack := '';
- end;
-
- procedure TAccessoriesMenu.Set_NextState(Value: Integer);
- begin
- FNextState := Value;
- end;
-
- procedure TAccessoriesMenu.DlgOption;
- var
- buf: String;
- i: Integer;
- begin
- buf := '5,' + IntToStr(FNextState) + ',' + '"' + FTitle + '",' + IntToStr(FSelected) + ',' + IntToStr(FMenuList.Count);
- for i := 0 to FMenuList.Count - 1 do begin
- buf := buf + ',"' + FMenuList.Strings[i] + '"';
- end;
-
- Form1.Debug('Dialog - One of Many');
- Form1.ScheduleTxAndWait('AT*EAID=' + buf);
- end;
-
- procedure TAccessoriesMenu.DlgMsgBox(const Msg: WideString;
- TimeoutS: Integer);
- var
- buf: String;
- begin
- buf := '1,' + IntToStr(FNextState) + ',"' + Msg + '"';
- if TimeoutS > 0 then begin
- if TimeoutS > 10 then Exception.Create('TimeoutS out of range (0-10)');
- buf := buf + ',' + IntToStr(TimeoutS * 10);
- end;
-
- Form1.Debug('Dialog - Messagebox');
- Form1.ScheduleTxAndWait('AT*EAID=' + buf);
- end;
-
- procedure TAccessoriesMenu.DlgYesNo(const Msg, Event: WideString;
- TimeoutS: Integer);
- var
- buf: String;
- begin
- FGeneralEvent := Event;
-
- buf := '2,' + IntToStr(FNextState) + ',"' + Msg + '"';
- if TimeoutS > 0 then begin
- if TimeoutS > 10 then Exception.Create('TimeoutS out of range (0-10)');
- buf := buf + ',' + IntToStr(TimeoutS * 10);
- end;
-
- Form1.Debug('Dialog - YesNo');
- Form1.ScheduleTxAndWait('AT*EAID=' + buf);
- end;
-
- procedure TAccessoriesMenu.DlgOnOff(const Title, Event: WideString;
- Default: Integer);
- var
- buf: String;
- begin
- FGeneralEvent := Event;
-
- buf := '3,' + IntToStr(FNextState) + ',"' + Title + '",' + IntToStr(Default);
- Form1.Debug('Dialog - OnOff');
- Form1.ScheduleTxAndWait('AT*EAID=' + buf);
- end;
-
- procedure TAccessoriesMenu.DlgPercent(const Title, Event: WideString;
- Steps, Pos: Integer);
- var
- buf: String;
- begin
- FGeneralEvent := Event;
-
- buf := '4,' + IntToStr(FNextState) + ',"' + Title + '",' + IntToStr(Steps) + ',' + IntToStr(pos);
- Form1.Debug('Dialog - Percent');
- Form1.ScheduleTxAndWait('AT*EAID=' + buf);
- end;
-
- procedure TAccessoriesMenu.DlgInputStr(const Title, Prompt: WideString; MaxLen: Integer;
- const DefaultStr: WideString; const Event: WideString);
- var
- buf: String;
- begin
- FGeneralEvent := Event;
-
- buf := '11,' + IntToStr(FNextState) + ',"' + Title + '","' + Prompt + '",' + IntToStr(maxLen) + ',"' + DefaultStr + '"';
- Form1.Debug('Dialog - InputStr');
- Form1.ScheduleTxAndWait('AT*EAID=' + buf);
- end;
-
- procedure TAccessoriesMenu.DlgInputInt(const Title, Prompt: WideString;
- MinVal, MaxVal, DefaultVal: Integer; const event: WideString);
- var
- buf: String;
- begin
- FGeneralEvent := Event;
-
- buf := '7,' + IntToStr(FNextState) + ',"' + Title + '","' + Prompt + '",' + IntToStr(MinVal) + ',' + IntToStr(MaxVal) + ',' + IntToStr(DefaultVal);
- Form1.Debug('Dialog - InputInt');
- Form1.ScheduleTxAndWait('AT*EAID=' + buf);
- end;
-
- procedure TAccessoriesMenu.DlgInformation(const Title, Msg: WideString);
- var
- buf: String;
- begin
- buf := '14,' + IntToStr(FNextState) + ',"' + Title + '","' + Msg + '"';
- Form1.Debug('Dialog - Information');
- Form1.ScheduleTxAndWait('AT*EAID=' + buf);
- end;
-
- procedure TAccessoriesMenu.DlgFeedback(const Title, event: WideString);
- var
- buf: String;
- begin
- FGeneralEvent := Event;
-
- buf := '13,' + IntToStr(FNextState) + ',"' + Title + '"';
- Form1.Debug('Dialog - Feedback');
- Form1.ScheduleTxAndWait('AT*EAID=' + buf);
- end;
-
- destructor TAccessoriesMenu.Destroy;
- begin
- FreeAndNil(FMenuList);
- FreeAndNil(FEventList);
- inherited;
- end;
-
- procedure TAccessoriesMenu.Initialize;
- begin
- inherited;
- FMenuList := TStringList.Create;
- FEventList := TStringList.Create;
- end;
-
- initialization
- TAutoObjectFactory.Create(ComServer, TAccessoriesMenu, Class_AccessoriesMenu,
- ciMultiInstance, tmApartment);
- end.
-